﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography.X509Certificates;
using System.Security;

namespace SecureCommander.Helper
{
    public class CertificateProvider
    {
        public static X509Certificate2Collection GetAllWindowCertificate()
        {
            X509Store store = new X509Store(StoreName.My);
            store.Open(OpenFlags.ReadWrite);

            store.Close();

            return store.Certificates;
        }

        public static void AddNewCertificate()
        {
            X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
            store.Open(OpenFlags.ReadWrite);


            byte[] x = Certificate.CreateSelfSignCertificatePfx("CN=aaaa", DateTime.Today, DateTime.Today.AddDays(5));
            X509Certificate2 c = new X509Certificate2(x);
            store.Add(c);

            store.Close();
        }
    }
}
